//
//  EGCrashReportSink.m
//  
//
//  Created by youzy01 on 2021/5/26.
//

#import "EGCrashReportSink.h"
#import "EGReportFormatter.h"
#import "KSCrashReportFields.h"

@implementation EGCrashReportSink

- (void)sendReport:(NSString *)report
              user:(NSDictionary<NSString *, NSString *>*)user
           reports:(NSArray *)reports
      onCompletion:(KSCrashReportFilterCompletion)onCompletion {

}

- (void)filterReports:(NSArray *)reports onCompletion:(KSCrashReportFilterCompletion)onCompletion {
    NSDictionary *data = reports.firstObject;

    NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:data];

    dict[@KSCrashField_BinaryImages] = nil;

    EGReportFormatter *formatter = [[EGReportFormatter alloc] init];
    NSString *string = [formatter toAppleFormat:dict];
    NSDictionary *user = data[@KSCrashExcType_User];

    [self sendReport:string user:user reports:@[data] onCompletion:onCompletion];
}

@end
